package edu.pitt.dbmi.odie.gapp.gwt.client.util.panel;

import java.util.List;

import com.allen_sauer.gwt.log.client.Log;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.layout.HLayout;

public class ODIE_IButtonPanel extends HLayout {

	public ODIE_IButtonPanel(String title, List<IButton> buttons) {
		
		this.setGroupTitle(title) ;
		this.setIsGroup(true) ;
		this.setLayoutMargin(20) ;
		this.setMembersMargin(20) ;
		this.setWidth100();
		
		for (IButton b : buttons) {
			b.setAlign(Alignment.CENTER) ;
			this.addMember(b) ;
		}
	}
	
	public static IButton buildIButton(String title) {
		IButton button = new IButton() ;
		button.setTitle(title) ;
		button.setWidth(100) ;
		return button ;
	}
	
	private String getHorizontalPercentage(List<IButton> buttons) {
		double numberOfButtons = Double.valueOf(buttons.size()) ;
		double numberOfHorizontalRegions = (2.0d * numberOfButtons) + 1.0d ;
		double percentagePerHorizontalRegion = (1.0d / numberOfHorizontalRegions) * 100.0d ;
		long percentagePerHorizontalRegionAsLong = Math.round(percentagePerHorizontalRegion) ;
		String result = percentagePerHorizontalRegionAsLong + "%" ;
		Log.debug("Each horizontal percent is " + result) ;
		return result ;
	}
	
}
